var twoSum = function (nums, target) {
    let map = new Map();
    let index = 0;
    let res = [];
    while (index < nums.length) {
        let value = target - nums[index];
        if (map.has(value)) {
            return [map.get(value), index]
        } else {
            map.set(nums[index], index)
        }
        index++
    }
    return res
};

console.log(twoSum([2, 7, 11, 15], 9))
